
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <sql:setDataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
                           url="jdbc:sqlserver://localhost\\hai:1443;databaseName=test;"
                           user="sa"
                           password="1243567"
                           var="conn"/>
        <sql:query var="users" dataSource="${conn}">
            SELECT * FROM [USER]
        </sql:query>

        <table border="1">
            <tr>
                <c:forEach var="colName" items="${users.columnNames}">
                    <th><c:out value="${colName}"/></th>
                </c:forEach>
            </tr>
            <c:forEach items="${users.rowsByIndex}" var="row">
                <tr>
                    <c:forEach var="col" items="${row}">
                        <td><c:out value="${col}"/> &nbsp;</td>
                    </c:forEach>
                </tr>
            </c:forEach>
        </table>
    </body>
</html>
